<?php
session_start();
require('dbconnection.php');
db_connect();


 $word = $_POST['name'];
 $username= $_SESSION['uname'];

 $numImages = $_POST['current'];

 $picturePath = $_POST['picture'];


 $picturePath= substr($picturePath,48,strlen($picturePath)-1);

 $query= "select number from pics where path='$picturePath' limit 1";	

 $result = mysql_query($query);

  if (!$result)
     throw new Exception("There is no result");    

 

  $image = mysql_fetch_row($result);


  //$datetime = date("Y-m-d H:i:s",time());
  $today = getdate();
  $datetime = $today['mday']."/".$today['mon']."/".$today['year'];
  $query= "insert into descriptors(word,user,numtaboowords,datetime,pic_number) values 
		('$word','$username','$numImages','$datetime','$image[0]')";
  $result = mysql_query($query);

  if (!$result)
     throw new Exception("There is no result");    


?>
